package com.example.transaction.sys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.transaction.sys.entity.Address;
import com.example.transaction.sys.entity.Chat;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;

import java.util.List;

@Mapper
public interface ChatMapper extends BaseMapper<Chat> {
    @Select("SELECT DISTINCT " +
            "CASE WHEN userID = #{userID} THEN targetUserID ELSE userID END AS chatUserID " +
            "FROM chat " +
            "WHERE userID = #{userID} OR targetUserID = #{userID}")
    List<Integer> findDistinctChatUserIDs(@Param("userID") Integer userID);
}
